#{extends 'main.html' /}
#{set title:'Registration' /}

<h2> Pay </h2>
    <table border="1">
    <tbody>
    <tr><td>Student </td> 
    <td><label> ${reg.student.getName()}</label>
    </td></tr>
    <tr><td>Course </td><td> ${course} </td></tr>
    <tr><td>Teacher </td><td> ${teacher} </td></tr>
    <tr><td>Number of Classes </td><td> ${n_classes} </td></tr>
    <tr><td>Number of Classes To Be Compensated</td><td> ${reg.classesToBeCompensated} </td></tr>
    
    <tr><td>Amount To Be Paid </td><td>  
    <form action="@{Application.editAmountToBePaid()}" method="POST">
    <input type="hidden" name="reg_id" value="${reg.id}"/>
    <input type="text" name="amount" value="${reg.amountToBePaid}"/>
    <input type="submit" value="+">
    
    </form>
    </td></tr>
    
    </tbody>
    </table>
    <h3>Classes</h3>
    <table border="1">
    <tr>
    <th> Class ID </th>
    <th> DateTime </th>
    <th> Student Attendance</th>
    <th> Teacher Attendance</th>
    
    </tr>
    	#{list items:classes, as:'cl'}
    	<tr>
    	<td>${cl.id}</td>
    	<td>${cl.datetime}</td>
    	<td>${cl.decodeA(cl.student_attendance)}</td>
    	<td>${cl.decodeA(cl.teacher_attendance)}</td>
    	</tr>
    	#{/list}
    </table>
    
    <br>
    
    <h3>Payments</h3>
    
    <table border="1">
    <tbody>
    <tr>
    <th> Payment Date </th>
    <th> Amount Paid </th>
    </tr>
    #{list items:ps, as:'p'}
    	<tr>
    	<td>${p.date}</td>
    	<td>${p.amount}</td>
    	</tr>
    	#{/list}
    
    </tbody>
    </table>
    <br>
    #{if reg.amountToBePaid > 0}
       
    <form id ="updateform" action="@{Application.pay()}" method="POST">
    
    Amount Paid <input type="text" name="amount" required="required"/>
    
    <input type="hidden" name="reg_id" value="${reg.id}"/>
    <br>
    <br>
    
    <input type="submit" value="Pay"/>
    </form>
    
    #{/if}
    


<br>
<br>
<br>